/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GodK
 * Date: 2024-07-22
 * Time: 21:04
 */
public class TEst {
    public static Object locker1 = new Object();
    public static Object locker2 = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            synchronized (locker1){
                System.out.println("t1加锁");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (locker2){
                    System.out.println("t2加锁");
                };
            };
        });
        Thread t2 = new Thread(()->{
            synchronized (locker2){
                System.out.println("t2加锁");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (locker1){
                    System.out.println("t1加锁");
                };
            };
        });
        t1.start();
        t2.start();
    }
}
